import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 设备分类信息 */
export interface DevCategory {
  id: number // 设备id
  status?: number // 启用状态
  code?: string // 编码
  name?: string // 名称
  upkeepCategory?: number // 保养类型
  description: string // 备注
  parentId?: number // 父id
  children?: DevCategory[]
}

// 设备分类 API
export const DevCategoryApi = {
  // 查询设备分类列表
  getDevCategoryList: async (params) => {
    return await request.get({ url: `/mold/dev-category/list`, params })
  },

  // 查询设备分类详情
  getDevCategory: async (id: number) => {
    return await request.get({ url: `/mold/dev-category/get?id=` + id })
  },

  // 新增设备分类
  createDevCategory: async (data: DevCategory) => {
    return await request.post({ url: `/mold/dev-category/create`, data })
  },

  // 修改设备分类
  updateDevCategory: async (data: DevCategory) => {
    return await request.put({ url: `/mold/dev-category/update`, data })
  },

  // 删除设备分类
  deleteDevCategory: async (id: number) => {
    return await request.delete({ url: `/mold/dev-category/delete?id=` + id })
  },

  // 导出设备分类 Excel
  exportDevCategory: async (params) => {
    return await request.download({ url: `/mold/dev-category/export-excel`, params })
  }
}
